<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/public/js/html5shiv.js"></script>
    <script type="text/javascript" src="/public/js/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/Hui-iconfont/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="/public/js/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>权限列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 权限列表 <a class="btn btn-success radius refresh r" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray title-action">
        <form method="post" id="search-form"  class="l">
<!--            <input type="text" name="keyword" placeholder="请输入名称/权限/条件" style="width:250px" class="input-text">-->
            <span class="select-box inline">
                <select name="is_menu" class="select">
                    <option value="">是否菜单</option>
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
            </span>
            <button type="submit" class="btn btn-success radius"><i class="Hui-iconfont"></i> 查询</button>
            <button type="reset" class="btn btn-white radius"><i class="Hui-iconfont">&#xe72a;</i> 清空</button>
        </form>
        <span class="r">
            <?php if ($auth['rule_add']): ?><a href="<?php echo site_url('auth/rule_add') ?>" class="btn btn-primary radius edit"><i class="Hui-iconfont">&#xe600;</i> 添加权限</a><?php endif ?>
            <?php if ($auth['rule_order']): ?><a href="<?php echo site_url('auth/rule_order') ?>" class="btn btn-secondary radius order"><i class="Hui-iconfont">&#xe6df;</i> 排序</a><?php endif ?>
        </span>
    </div>
    <div class="mt-10 cl">
    <?php $auth_action = $auth['rule_add'] || $auth['rule_edit'] || $auth['rule_del'] ?>
    <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive" id="dataTables">
        <thead>
        <tr class="text-c">
            <th>名称</th>
            <th>权限</th>
            <th>条件</th>
            <th>图标</th>
            <th>是否菜单</th>
            <th>排序</th>
            <?php if ($auth_action): ?><th style="width:120px">操作</th><?php endif ?>
        </tr>
        </thead>
    </table>
    </div>
</div>
<script type="text/javascript" src="/public/js/jquery.min.js"></script>
<script type="text/javascript" src="/public/plugins/layer/layer.js"></script>
<script type="text/javascript" src="/public/plugins/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/public/plugins/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/public/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript">
    var dataTables = $('#dataTables').my_data_table({
        ordering: false,
        searching: false,
        paging: false,
        columns: [
            {data: '_name'},
            {data: 'name'},
            {data: 'condition'},
            {data: 'icon', render: function(data, type, row, meta) {
                return data.length > 0 ? '<i class="Hui-iconfont">' + data + '</i>' : '';
            }},
            {data: 'is_menu', render: function(data, type, row, meta) {
                return data == 1 ? '<span class="c-red">是</span>' : '否';
            }},
            {data: 'ord', className: 'pd-0', render: function (data, type, row, meta) {
                return <?php if ($auth['rule_order']): ?>'<input type="number" name="ord[' + row['id'] + ']" class="input-text size-S ml-5" style="width:60px;" value="' + data + '">'<?php else: ?>data<?php endif ?>;
            }},
            <?php if ($auth_action): ?>
            {data: 'id', render: function (data, type, row, meta) {
                var html ='';
                <?php if ($auth['rule_add']): ?>html +='<a href="<?php echo site_url('auth/rule_add') ?>?pid=' + data + '" class="edit">添加子权限</a> ';<?php endif ?>
                <?php if ($auth['rule_edit']): ?>html +='<a href="<?php echo site_url('auth/rule_edit') ?>?id=' + data + '" class="edit">编辑</a> ';<?php endif ?>
                <?php if ($auth['rule_del']): ?>html +='<a href="<?php echo site_url('auth/rule_del') ?>?id=' + data + '" class="del">删除</a> ';<?php endif ?>
                return html;
            }}
            <?php endif ?>
        ]
    });

    $("#dataTables tbody,.title-action").on("click", ".edit", function() {
        var url = $(this).attr('href');
        layer.open({type: 2, title: '权限添加', shadeClose: true, shade: 0.8, area: ['80%', '80%'], maxmin: true, content: url});
        return false;
    }).on("click", ".del", function() {
        var obj = $(this), url = obj.attr('href'), txt = obj.text();
        var index = layer.confirm('您确定要' + txt + '此权限吗？', function(){
            return $.change_status({url: url, layer: layer, index: index});
        });
        return false;
    });
    $('.order').on('click', function() {
        var obj = $(this), url = obj.attr('href');
        var data = $('#dataTables').find('input').serialize();
        return $.change_status({url: url, data: data, table: 1});
    })
</script>
</body>
</html>